package com.dduggs.controller;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * @author Created by CJS on 2018/4/17
 * @ClassName:
 * @Description:
 */
public class ThreadTest {
    public static void main(String[] args) throws Exception{
        HashMap<String,Object> map=new HashMap<>();
        map.put("1",1);
        map.put("2",2);
        map.put("3",3);
        map.put("4",4);

        Iterator<Map.Entry<String,Object>> it=map.entrySet().iterator();

        Thread t1= new Thread(() -> {

            try{
                it.remove();

            }catch (Exception e){

            }

        });

        while (it.hasNext()) {

            Map.Entry<String,Object> entry=it.next();
            System.out.println(entry.getKey()+" "+entry.getValue());
            if(entry.getKey().equals("2")){
                t1.start();
                Thread.sleep(1000);
            }
        }


    }
}
